<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<%@ taglib uri="/assistant.tld" prefix="at"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>家庭理财</title>
<at:res base="webRoot"/>
<at:res css="/res/scripts/yui/reset-fonts-grids/reset-fonts-grids.css" />
<at:res css="/res/scripts/yui/button/assets/skins/sam/button.css" />
<at:res css="/res/scripts/yui/container/assets/skins/sam/container.css" />
<at:res css="/res/themes/default/css/assistant.css" />

<at:res js="/res/scripts/yui/yahoo-dom-event/yahoo-dom-event.js" />
<at:res js="/res/scripts/yui/connection/connection-min.js" />
<at:res js="/res/scripts/yui/element/element-min.js" />
<at:res js="/res/scripts/yui/button/button-min.js" />
<at:res js="/res/scripts/yui/dragdrop/dragdrop-min.js" />
<at:res js="/res/scripts/yui/container/container-min.js" />
</head>
<body class="yui-skin-sam">
<div id="dialog">
	<div class="hd">登录</div>
	<div class="bd">
		<div class="yui-g">
			<div id="msg"></div>
		</div>
		<div class="yui-g">
			<form method="POST" action="hcm/login.t?m=doLogin">
			<table cellspacing="0" class="yui-skin-sam noborder_table">
				<tbody>
					<tr>
						<th width="40%">
							<label for="login">账号： </label>
						</th>
						<td width="60%">
							<input type="text" id="login" name="login" />
						</td>
					</tr>
					<tr>
						<th><label for="password">密码： </label></th>
						<td><input type="password" id="password" name="password" /></td>
					</tr>
				</tbody>
			</table>
			</form>
		</div>
	</div>
</div>
</body>
</html>
<at:res js="/res/scripts/assistant.js" />
<script language="JavaScript">
function init() {
	// Define various event handlers for Dialog
	var handleSubmit = function() {
		this.submit();
	};
	var handleCancel = function() {
		document.getElementById("login").value = "";
		document.getElementById("password").value = "";
		document.getElementById("login").focus();
	};
	var handleSuccess = function(o) {
		var resultData = new ResultData(o);
		if(resultData.isSuccess()){
			document.getElementById("msg").innerHTML = resultData.getData().msg;
			document.location.href = "hcm/main.t?m=index";
		}else{
			document.getElementById("msg").innerHTML = "<font color='#FF0000'>"+resultData.getMessage()+"</font>";
		}
		dialog.show();
	};
	var handleFailure = function(o) {
		alert("登录失败：" + o.status);
	};

	// Instantiate the Dialog
	var dialog = new YAHOO.widget.Dialog("dialog", 
							{ width : "20em",
							  fixedcenter : true,
							  visible : false, 
							  constraintoviewport : true,
							  close : false,
							  buttons : [ { text:"登录", handler:handleSubmit, isDefault:true },
								      { text:"重置", handler:handleCancel } ]
							});

	// Validate the entries in the form to require that both first and last name are entered
	dialog.validate = function() {
		var data = this.getData();
		if (data.login == "") {
			alert("请输入登录账号。");
			return false;
		} else if(data.password == "") {
			alert("请输入登录密码。");
		} else {
			return true;
		}
	};

	// Wire up the success and failure handlers
	dialog.callback = { success: handleSuccess,
						     failure: handleFailure };
	
	// Render the Dialog
	dialog.render();
	
	dialog.show();
}

YAHOO.util.Event.onDOMReady(init);
</script>
